package com.ethink.system.facade.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ethink.system.api.SystemUserFacade;
import com.ethink.system.api.info.SystemUserInfo;
import com.ethink.system.api.info.SystemUserSessionInfo;
import com.ethink.system.api.request.SystemUserAddRequest;
import com.ethink.system.api.request.SystemUserListRequest;
import com.ethink.system.api.request.SystemUserQueryRequest;
import com.ethink.system.api.request.SystemUserUpdateRequest;
import com.ethink.system.api.response.SystemUserAddResponse;
import com.ethink.system.api.response.SystemUserDeleteResponse;
import com.ethink.system.api.response.SystemUserDetailResponse;
import com.ethink.system.api.response.SystemUserUpdateResponse;
import com.ethink.system.manager.SystemUserSessionManager;
import com.ethink.system.service.SystemUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 系统用户表 Facade接口实现
 *
 * @author default
 * @date 2022-09-26
 */
@RestController
@Slf4j
@RequestMapping("system-service/facade/v1/systemUser")
public class SystemUserFacadeImpl implements SystemUserFacade {

    @Autowired
    private SystemUserService systemUserService;

    @Autowired
    private SystemUserSessionManager systemUserSessionManager;

    @Override
    public Page<SystemUserInfo> querySystemUser(SystemUserQueryRequest request) {
        return systemUserService.querySystemUser(request);
    }

    @Override
    public SystemUserDetailResponse getSystemUserById(Long systemUserId) {
        return systemUserService.getSystemUserById(systemUserId);
    }

    @Override
    public List<SystemUserInfo> listSystemUser(SystemUserListRequest request) {
        return systemUserService.listSystemUser(request);
    }

    @Override
    public SystemUserAddResponse addSystemUser(SystemUserAddRequest request) {
        return systemUserService.addSystemUser(request);
    }

    @Override
    public SystemUserUpdateResponse updateSystemUser(SystemUserUpdateRequest request) {
        return systemUserService.updateSystemUser(request);
    }

    @Override
    public SystemUserDeleteResponse deleteSystemUser(Long systemUserId) {
        return systemUserService.deleteSystemUser(systemUserId);
    }

    @Override
    public SystemUserSessionInfo getSystemUserSession(String loginName) {
        return systemUserSessionManager.getSystemUserSession(loginName);
    }

    @Override
    public SystemUserSessionInfo loginByAccessToken(String token) {
        return systemUserSessionManager.loginByAccessToken(token);
    }

}